/**
 * ======================================
 * 选择列数据
 * author: sky
 * file: select.js
 * date: 2022/6/26 15:15
 * ======================================
 */
import { buildingColumn } from '@/api/building'
import { getPermission, getPermissionTree, getRoleList } from '@/api/system'
import { getAddress, getAdminList } from '@/api/common'
export default {
  data() {
    return {
      buildingList: [],
      adminList: [],
      permissionList: [],
      permissionTreeList: [],
      provinceList: [],
      cityList: [],
      areaList: [],
      streetList: [],
      roleList: []
    }
  },
  methods: {
    getBuildingList() {
      buildingColumn().then(res => {
        this.buildingList = res.data
      })
    },
    getAdmin() {
      getAdminList().then(res => {
        this.adminList = res.data.children
      })
    },
    getPermission() {
      getPermission().then(res => {
        this.permissionList = res.data
      })
    },
    getPermissionTree() {
      getPermissionTree().then(res => {
        this.permissionTreeList = res.data
      })
    },
    getRole() {
      getRoleList({ page: { size: 1000, number: 1 }}).then(res => {
        console.log('角色列表', res.data.children)
        this.roleList = res.data.children
      })
    },
    async getProvince() {
      const data = await getAddress({})
      this.provinceList = data.data
      this.cityList = []
      this.areaList = []
      this.streetList = []
      console.log('省', this.provinceList)
    },
    async getCity(provinceId) {
      const data = await getAddress({ province: provinceId })
      this.cityList = data.data
      this.areaList = []
      this.streetList = []
      console.log('市', this.cityList)
    },
    async getArea(provinceId, cityId) {
      const data = await getAddress({ province: provinceId, city: cityId })
      this.areaList = data.data
      this.streetList = []
      console.log('区', this.areaList)
    },
    async getStreet(provinceId, cityId, areaId) {
      const data = await getAddress({ province: provinceId, city: cityId, area: areaId })
      this.streetList = data.data
      console.log('街道', this.streetList)
    }
  }
}
